
package com.shop.cloud.mall.api.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.cloud.common.core.util.R;
import com.shop.cloud.common.portal.annotation.ApiLogin;
import com.shop.cloud.mall.api.service.OrderRefundsService;
import com.shop.cloud.mall.common.entity.OrderRefunds;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 退款详情
 *
 * @author
 * @date 2019-11-14 16:35:25
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/orderrefunds")
@Tag(description = "orderrefunds", name = "退款详情API")
public class OrderRefundsController {

    private final OrderRefundsService orderRefundsService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param orderRefunds 退款详情
     * @return
     */
	@Operation(summary = "分页查询")
    @GetMapping("/page")
	@ApiLogin
    public R getOrderRefundsPage(Page page, OrderRefunds orderRefunds) {
		return R.ok(orderRefundsService.page(page, Wrappers.query(orderRefunds)));
    }

    /**
     * 通过id查询退款详情
     * @param id
     * @return R
     */
	@Operation(summary = "通过id查询退款详情")
    @GetMapping("/{id}")
	@ApiLogin
    public R getById(@PathVariable("id") String id) {
		return R.ok(orderRefundsService.getById(id));
    }

    /**
     * 新增退款详情(发起退款)
     * @param orderRefunds 退款详情
     * @return R
     */
	@Operation(summary = "新增退款详情")
    @PostMapping
	@ApiLogin
    public R save(@RequestBody OrderRefunds orderRefunds) {
		return R.ok(orderRefundsService.saveRefunds(orderRefunds));
    }

    /**
     * 修改退款详情
     * @param orderRefunds 退款详情
     * @return R
     */
	@Operation(summary = "修改退款详情")
    @PutMapping
    public R updateById(@RequestBody OrderRefunds orderRefunds) {
		return R.ok(orderRefundsService.updateById(orderRefunds));
    }

}
